﻿@model IEnumerable<HanGu.Entity.Manager>
@{
    ViewBag.Title = "用户管理";
    int i = 1;
    var Roles = ViewData["Roles"] as SelectList;
    var Parents = ViewData["Parents"] as List<HanGu.Entity.Manager>;
    var UserStatus = ViewData["UserStatus"] as SelectList;
    var SearchParma = ViewData["SearchParma"] as HanGu.Entity.UniversallySearchParam;

    var CurentUser = Session["CurentUser"] as HanGu.Entity.CurrentUserDTO;

}
<form id="pagerForm" method="get" action="/Users/Default/index?action=page&OpID=@ViewData["OperateID"]">
<input type="hidden" name="pageNum" value="1" />
<input type="hidden" name="numPerPage" value="@ViewData["pageSize"]" />
<input type="hidden" name="RowCount" value="@ViewData["RowCount"]" />
<input type="hidden" name="Title" value="@SearchParma.Ttile" />
<input type="hidden" name="IntObj2" value="@SearchParma.IntObj2" />
<input type="hidden" name="IntObj1" value="@SearchParma.IntObj1" />
<input type="hidden" name="Suitabler" value="@SearchParma.Suitabler" />
<input type="hidden" name="ClassType" value="@SearchParma.ClassType" />
<input type="hidden" name="StarDateTime" value="@SearchParma.StarDateTime" />
<input type="hidden" name="EndDateTime" value="@SearchParma.EndDateTime" />
</form>
<script>
    $("#IntObj1").val("@SearchParma.IntObj1");
    $("#IntObj2").val("@SearchParma.IntObj2");
    $("#ClassType").val("@SearchParma.ClassType");
</script>
<div class="pageHeader">
    <form onsubmit="return navTabSearch(this);" id="Form_@ViewData["CurrentController"]" action="/Users/Default/index?action=search&OpID=@ViewData["OperateID"]"
    method="post">
    <div class="searchBar">
        <table class="searchContent">
            <tr>
                <td>
                    用户名：
                </td>
                <td>
                    @Html.TextBox("Title1", SearchParma.Ttile)
                </td>
                <td>
                    姓 名：
                </td>
                <td>
                    @Html.TextBox("Suitabler", SearchParma.Suitabler)
                </td>
                @*<td>
                    上 级：
                </td>
                <td>
                    @Html.DropDownList("IntObj1", Parents, HanGu.CRM.HelperCommon.SelectDefaultValue)
                </td>*@
                <td>
                    状 态：
                </td>
                <td>
                    @Html.DropDownList("IntObj2", UserStatus, HanGu.CRM.HelperCommon.SelectDefaultValue)
                </td>
            </tr>
            <tr>
                <td>
                    角 色：
                </td>
                <td>
                    @Html.DropDownList("ClassType", Roles, HanGu.CRM.HelperCommon.SelectDefaultValue)
                </td>
                <td>
                    入职时间：
                </td>
                <td>
                    @Html.TextBox("StarDateTime", SearchParma.StarDateTime, new { @class = "date", format = "yyyy-MM-dd", @readonly = "true" })
                </td>
                <td colspan="2">
                    ~
                    @Html.TextBox("EndDateTime", SearchParma.EndDateTime, new { @class = "date", format = "yyyy-MM-dd", @readonly = "true" })
                </td>
                <td align="right">
                    <div class="subBar">
                        <ul>
                            <li>
                                <div class="buttonActive">
                                    <div class="buttonContent">
                                        <button type="submit" name="submit">
                                            检索</button></div>
                                </div>
                            </li>
                        </ul>
                    </div>
                </td>
            </tr>
        </table>
    </div>
    </form>
</div>
<div class="pageContent">
    @Html.Partial("Buttons")
    <table class="table" width="100%" layouth="170">
        <thead>
            <tr class="header">
                <th style="width: 80px">
                    序号
                </th>
                <th>
                    用户名
                </th>
                <th>
                    角色
                </th>
                <th>
                    上级
                </th>
                @*<th>
                    是否直属
                </th>*@
                <th>
                    状态
                </th>
                <th>
                    入职时间
                </th>
                <th>
                    操作
                </th>
            </tr>
        </thead>
        @foreach (var item in Model)
        {            
            <tr target="Users_ID" rel="@item.ID" >
                <td>
                    @i
                </td>
                <td>
                    @item.RealName@item.User
                </td>
                <td>
                    @{var tmprole = Roles.Where(c => item.RoleID.HasValue && c.Value == item.RoleID.Value.ToString()).FirstOrDefault();
                      if (tmprole != null)
                      {
                        @tmprole.Text
                      }
                    }
                </td>
                <td>
                    @if (item.Parents != null)
                    {
                        var parents = string.Join(" ", item.Parents.Select(c => c.RealName + c.User));
                        @parents
                    }
                </td>
               @* <td>
                    @if (item.IsDirectly.HasValue && item.IsDirectly.Value)
                    {
                        <span>是</span>
                    }
                    else
                    { <span>否</span>
                    }
                </td>*@
                <td>
                    @{var tmpStatus = UserStatus.Where(c => item.Status.HasValue && c.Value == item.Status.Value.ToString()).FirstOrDefault();
                      if (tmpStatus != null)
                      {
                        @tmpStatus.Text
                      }
                    }
                </td>
                <td>
                    <span formatdate="yyyy-MM-dd">
                        @item.InWorkDate</span>
                </td>
                <td>
                    @if (CurentUser.Roles.Where(c => c.ID == "Users_5").FirstOrDefault() != null)
                    {
                        <a class="edit" style=" margin-left:10px" href='Users/Default/ReSetPwd/@item.ID?OpID=@ViewData["OperateID"]' target="navTab" rel="ReSetPwd">
                            修改密码</a>
                    }
                </td>
            </tr>
                    i += 1;
        }
    </table>
</div>
@Html.Partial("_PagePartial")
